package sany.iec.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author 托马斯
 * @Date 2025/7/5 21:21
 * @Description IEC104DataTypeEnum
 */
@AllArgsConstructor
@Getter
public enum IEC104DataTypeEnum {

    C_SC_NA("C_SC_NA", 45, "单点遥控"),

    C_DC_NA("C_DC_NA", 46,  "双点遥控"),

    M_SP_NA("M_SP_NA", 1, "单点遥信"),

    M_DP_NA("M_DP_NA", 3, "双点遥信"),

    C_SE_NC("C_SE_NC", 50, "遥调"),

    M_ME_NC("M_ME_NC", 13, "遥测"),

    ;

    private final String type;

    private final Integer code;

    private final String description;

    public static IEC104DataTypeEnum getIEC104DataTypeEnum(String type) {
        if (StringUtils.isBlank(type)) {
            return null;
        }
        for (IEC104DataTypeEnum iec104DataTypeEnum : IEC104DataTypeEnum.values()) {
            if (type.toLowerCase().contains(iec104DataTypeEnum.getType().toLowerCase())) {
                return iec104DataTypeEnum;
            }
        }
        return null;
    }

}
